from gate.gateAPI import GateIO
import json

API_URL = 'data.gate.io'
def GetCoinNum(coinjson, ak, sk):
    bfc = GateIO(API_URL, ak, sk)
    coins = json.loads(bfc.balances())
    #print(coins)
    myCoins = coins['available']

    for i in myCoins.keys():
        num = (float)(myCoins[i])
        if num > 0:
            if i.lower() in coinjson.keys():
                coinjson[i.lower()] = coinjson[i.lower()] + num
            else:
                coinjson[i.lower()] = num
    if 'locked' in coins:
        myCoins = coins['locked']

        for i in myCoins.keys():
            num = (float)(myCoins[i])
            if num > 0:
                if i.lower() in coinjson.keys():
                    coinjson[i.lower()] = coinjson[i.lower()] + num
                else:
                    coinjson[i.lower()] = num

